package com.qian.fmall.portal;

import com.qian.fmall.banner.BannerInterface;
import com.qian.fmall.commons.ResultSet;
import com.qian.fmall.pojo.IndexImg;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/banner")
@CrossOrigin
public class BannerController {
    @DubboReference
    private BannerInterface  bannerInterface;
    @RequestMapping("list")
    public ResultSet getAllBanner(){
        ResultSet banner = bannerInterface.getBanner();
        List<IndexImg> data = (List<IndexImg>)banner.getData();
        for (IndexImg datum : data) {
            datum.setImgUrl("http://192.168.56.103:8888/"+datum.getImgUrl());
        }
        banner.setData(data);
        return banner;
    }
}
